/*
 * All content copyright http://www.j2eefast.com, unless
 * otherwise indicated. All rights reserved.
 * No deletion without permission
 */
package com.j2eefast.web.service;

import com.j2eefast.web.entity.ItemSkuPriceEntity;
import com.j2eefast.web.mapper.ItemSkuPriceMapper;
import com.j2eefast.common.core.page.Query;
import com.j2eefast.common.core.utils.PageUtil;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.j2eefast.common.core.utils.ToolUtil;
import com.j2eefast.framework.utils.Constant;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import javax.annotation.Resource;
import org.springframework.transaction.annotation.Transactional;
import java.util.Map;
import java.util.List;
import java.util.Arrays;

/**
 * 【请填写功能名称】Service接口
 * @author: ZhouZhou
 * @date 2021-06-11 10:29:57
 */
@Service
public class ItemSkuPriceService extends ServiceImpl<ItemSkuPriceMapper,ItemSkuPriceEntity> {

	@Resource
	private ItemSkuPriceMapper itemSkuPriceMapper;

	/**
	 * mybaitis-plus 单表页面分页查询
     */
	public PageUtil findPage(Map<String, Object> params) {
		QueryWrapper<ItemSkuPriceEntity> queryWrapper = new QueryWrapper<ItemSkuPriceEntity>();
		String itemSkuId = (String) params.get("itemSkuId");
        queryWrapper.eq(ToolUtil.isNotEmpty(itemSkuId), "item_sku_id", itemSkuId);
		String price = (String) params.get("price");
        queryWrapper.eq(ToolUtil.isNotEmpty(price), "price", price);
		String priceName = (String) params.get("priceName");
        queryWrapper.like(ToolUtil.isNotEmpty(priceName), "price_name", priceName);
		String typeCode = (String) params.get("typeCode");
        queryWrapper.eq(ToolUtil.isNotEmpty(typeCode), "type_code", typeCode);
		Page<ItemSkuPriceEntity> page = itemSkuPriceMapper.selectPage(new Query<ItemSkuPriceEntity>(params).getPage(), queryWrapper);
		return new PageUtil(page);
    }

	/**
	 * 自定义分页查询，含关联实体对像
	 */
	public PageUtil findPage(Map<String, Object> params,ItemSkuPriceEntity itemSkuPriceEntity) {
		Page<ItemSkuPriceEntity> page = itemSkuPriceMapper.findPage(new Query<ItemSkuPriceEntity>(params).getPage(),
					itemSkuPriceEntity,
				(String) params.get(Constant.SQL_FILTER));
		return new PageUtil(page);
	}

	/**
	* 查列表
	*/
	public List<ItemSkuPriceEntity> findList(ItemSkuPriceEntity itemSkuPriceEntity){
		return itemSkuPriceMapper.findList(itemSkuPriceEntity);
	}

	/**
     * 批量删除
     */
	@Transactional(rollbackFor = Exception.class)
	public boolean deleteBatchByIds(Long[] ids) {
		return this.removeByIds(Arrays.asList(ids));
	}

	/**
     * 单个删除
     */
	@Transactional(rollbackFor = Exception.class)
	public boolean delItemSkuPriceById(Long pkId) {
		return this.removeById(pkId);
	}

	/**
     * 保存
     */
	@Transactional(rollbackFor = Exception.class)
	public boolean addItemSkuPrice(ItemSkuPriceEntity itemSkuPrice){
		if(this.save(itemSkuPrice)){
			return true;
		}
        return false;
    }

	/**
     * 修改根居ID
     */
	@Transactional(rollbackFor = Exception.class)
	public boolean updateItemSkuPriceById(ItemSkuPriceEntity itemSkuPrice) {
		if(this.updateById(itemSkuPrice)){
			return true;
		}
		return false;
	}

	/**
     * 根居ID获取对象
     */
	public ItemSkuPriceEntity findItemSkuPriceById(Long pkId){
		return itemSkuPriceMapper.findItemSkuPriceById(pkId);
	}


}
